package Renderer;

/**
 * This represents all formatting that need to be done on each item of Text,
 * such as what font it is, whether it is a heading, etc.
 * @author Nathan Scully
 * @version FINAL
 */
public class TextProperty implements Cloneable 
{
    private String link;
    private boolean isLink;
    private String font;
    private int size;
    private String color;
    private boolean isBold;
    private boolean isUnderlined;
    private boolean isItalic;
    private boolean isTitle;
    private boolean isPre;
    private boolean isBlock;
    private boolean isDL;
    private boolean isDT;
    private boolean isDD;
    private boolean isH1;
    private boolean isH2;
    private boolean isH3;

    /**
     * The Constructor, which specifies the default values.
     */
    public TextProperty()
    {
        font = "Times New Roman";
        size = 11;
        color = "black";
        isBold = false;
        isLink = false;
        link = "";
        isUnderlined = false;
        isItalic = false;
        isTitle = false;
        isPre = false;
        isBlock = false;
        isDL = false;
        isDT = false;
        isDD = false;
        isH1 = false;
        isH2 = false;
        isH3 = false;
    }
    
    /**
     * This will create a new TextProperty object, then copy all of the values
     * from this TextProperty to the new one and return it.
     * @return The cloned TextProperty object as an Object.
     */
    public Object clone()
    {
        TextProperty clonedTextProperty = new TextProperty();
        clonedTextProperty.setBlock(isBlock);
        clonedTextProperty.setBold(isBold);
        clonedTextProperty.setTitle(isTitle);
        clonedTextProperty.setColor(color);
        clonedTextProperty.setLink(isLink, link);
        clonedTextProperty.setDD(isDD);
        clonedTextProperty.setDL(isDL);
        clonedTextProperty.setDT(isDT);
        clonedTextProperty.setFont(font);
        clonedTextProperty.setItalic(isItalic);
        clonedTextProperty.setPre(isPre);
        clonedTextProperty.setSize(size);
        clonedTextProperty.setUnderlined(isUnderlined);
        clonedTextProperty.setH1(isH1);
        clonedTextProperty.setH2(isH2);
        clonedTextProperty.setH3(isH3);
        return clonedTextProperty;
    }

    /**
     * Returns whether or not the current text should be a heading of level 1.
     * @return True or false.
     */
    public boolean isH1()
    {
        return isH1;
    }

    /**
     * Sets whether or not the current text should be a heading of level 1.
     * @param H1 True or false.
     */
    public void setH1(boolean H1)
    {
        isH1 = H1;
    }

    /**
     * Returns whether or not the current text should be a heading of level 2.
     * @return True or false.
     */
    public boolean isH2()
    {
        return isH2;
    }

    /**
     * Sets whether or not the current text should be a heading of level 2.
     * @param H2 True or false.
     */
    public void setH2(boolean H2)
    {
        isH2 = H2;
    }

    /**
     * Returns whether or not the current text should be a heading of level 3.
     * @return True or false.
     */
    public boolean isH3()
    {
        return isH3;
    }
    
    /**
     * Sets whether or not the current text should be a heading of level 3.
     * @param H3 True or false.
     */
    public void setH3(boolean H3)
    {
        isH3 = H3;
    }

    /**
     * Returns whether or not the current text should be a link.
     * @return True or false.
     */
    public boolean getIsLink()
    {
        return isLink;
    }

    /**
     * Reterns the address of the link to be assigned to the link text.
     * @return The address of the current link.
     */
    public String getLink()
    {
        return link;
    }

    /**
     * Sets whether the current text should be a link and what it should link to.
     * @param isLink If the current text is a link.
     * @param link The address it should link to.
     */
    public void setLink(boolean isLink, String link)
    {
        this.isLink = isLink;
        this.link = link;
    }

    /**
     * Returns the name of the current font.
     * @return The current font as a String.
     */
    public String getFont()
    {
        return font;
    }

    /**
     * Specifies the font to be used.
     * @param font The name of the font to be used.
     */
    public void setFont(String font)
    {
        this.font = font;
    }
    
    /**
     * Returns the size of the current font.
     * @return The size of the current font.
     */
    public int getSize()
    {
        return size;
    }
    
    /**
     * Sets the size of the current font.
     * @param size The size of the current font.
     */
    public void setSize(int size)
    {
        this.size = size;
    }
    
    /**
     * Returns the name of the colour of the current font.
     * @return The colour of the current font as a String.
     */
    public String getColor()
    {
        return color;
    }
    
    /**
     * Specifies the name of the colour to be used.
     * @param color The colour to be used as a String.
     */
    public void setColor(String color)
    {
        this.color = color;
    }
    
    /**
     * Returns whether or not the current text should be written as bold text.
     * @return True or false.
     */
    public boolean isBold()
    {
        return isBold;
    }
    
    /**
     * Sets whether or not the current text should be written as bold text.
     * @param isBold True or false.
     */
    public void setBold(boolean isBold)
    {
        this.isBold = isBold;
    }
    
    /**
     * Returns whether or not the current text should be written with an underline.
     * @return True or false.
     */
    public boolean isUnderlined()
    {
        return isUnderlined;
    }
    
    /**
     * Sets whether or not the current text should be written with an underline.
     * @param isUnderlined True or false.
     */
    public void setUnderlined(boolean isUnderlined)
    {
        this.isUnderlined = isUnderlined;
    }
    
    /**
     * Returns whether or not the current text should be written as italic text.
     * @return True or false.
     */
    public boolean isItalic()
    {
        return isItalic;
    }
    
    /**
     * Sets whether or not the current text should be written as italic text.
     * @param isItalic True or false.
     */
    public void setItalic(boolean isItalic)
    {
        this.isItalic = isItalic;
    }
    
    /**
     * Returns whether or not the current text should be in the window's title bar.
     * @return True or false.
     */
    public boolean isTitle()
    {
        return isTitle;
    }
    
    /**
     * Sets whether or not the current text should be in the window's title bar.
     * @param isTitle True or false.
     */
    public void setTitle(boolean isTitle)
    {
        this.isTitle = isTitle;
    }
    
    /**
     * Returns whether or not the current text should be written as preformatted text.
     * @return True or false.
     */
    public boolean isPre()
    {
        return isPre;
    }
    
    /**
     * Sets whether or not the current text should be written as preformatted text.
     * @param isPre True or false.
     */
    public void setPre(boolean isPre)
    {
        this.isPre = isPre;
    }
    
    /**
     * Returns whether or not the current text should be written as a blockquote.
     * @return True or false.
     */
    public boolean isBlock()
    {
        return isBlock;
    }
    
    /**
     * Sets whether or not the current text should be written as a blockquote.
     * @param isBlock True or false.
     */
    public void setBlock(boolean isBlock)
    {
        this.isBlock = isBlock;
    }
    
    /**
     * Returns whether or not the current text is part of a definition list.
     * @return True or false.
     */
    public boolean isDL()
    {
        return isDL;
    }
    
    /**
     * Sets whether or not the current text is part of a definition list.
     * @param isDL True or false.
     */
    public void setDL(boolean isDL)
    {
        this.isDL = isDL;
    }
    
    /**
     * Returns whether or not the current text should be written as a definition topic.
     * @return True or false.
     */
    public boolean isDT()
    {
        return isDT;
    }
    
    /**
     * Sets whether or not the current text should be written as a definition topic.
     * @param isDT True or false.
     */
    public void setDT(boolean isDT)
    {
        this.isDT = isDT;
    }
    
    /**
     * Returns whether or not the current text should be written as a definition.
     * @return True or false.
     */
    public boolean isDD()
    {
        return isDD;
    }
    
    /**
     * Sets whether or not the current text should be written as a definition.
     * @param isDD True or false.
     */
    public void setDD(boolean isDD)
    {
        this.isDD = isDD;
    }

    /**
     * Decides what combination of Bold and Italic is being used and returns the
     * corresponding java.awt.Font value.
     * @return A java.awt.Font value corresponing to the current font.
     */
    public int getStyle()
    {
        if(isBold && !isItalic)
        {
            //java.awt.Font.BOLD
            return 1;
        }

        if(isItalic && !isBold)
        {
            //java.awt.Font.ITALIC
            return 2;
        }

        if(isItalic && isBold)
        {
            return 3;
        }
        return java.awt.Font.PLAIN;
    }
}
